package com.oa.xinxi.dao;

import com.oa.xinxi.entity.JianBao;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

public interface JianBaoMapper {
    @Delete({
        "delete from jianbao",
        "where jianbao_id = #{jianbaoId,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer jianbaoId);

    @Insert({
        "insert into jianbao (jianbao_id, title, ",
        "creator, createtime, ",
        "updator, updatetime, ",
        "jianbao_content)",
        "values (#{jianbaoId,jdbcType=INTEGER}, #{title,jdbcType=VARCHAR}, ",
        "#{creator,jdbcType=VARCHAR}, #{createtime,jdbcType=TIMESTAMP}, ",
        "#{updator,jdbcType=VARCHAR}, #{updatetime,jdbcType=TIMESTAMP}, ",
        "#{jianbaoContent,jdbcType=LONGVARCHAR})"
    })
    int insert(JianBao record);

    @InsertProvider(type=JianBaoSqlProvider.class, method="insertSelective")
    int insertSelective(JianBao record);

    @Select({
        "select",
        "jianbao_id, title, creator, createtime, updator, updatetime, jianbao_content",
        "from jianbao",
        "where jianbao_id = #{jianbaoId,jdbcType=INTEGER}"
    })
    @Results({
        @Result(column="jianbao_id", property="jianbaoId", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="title", property="title", jdbcType=JdbcType.VARCHAR),
        @Result(column="creator", property="creator", jdbcType=JdbcType.VARCHAR),
        @Result(column="createtime", property="createtime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="updator", property="updator", jdbcType=JdbcType.VARCHAR),
        @Result(column="updatetime", property="updatetime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="jianbao_content", property="jianbaoContent", jdbcType=JdbcType.LONGVARCHAR)
    })
    JianBao selectByPrimaryKey(Integer jianbaoId);

    @UpdateProvider(type=JianBaoSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(JianBao record);

    @Update({
        "update jianbao",
        "set title = #{title,jdbcType=VARCHAR},",
          "creator = #{creator,jdbcType=VARCHAR},",
          "createtime = #{createtime,jdbcType=TIMESTAMP},",
          "updator = #{updator,jdbcType=VARCHAR},",
          "updatetime = #{updatetime,jdbcType=TIMESTAMP},",
          "jianbao_content = #{jianbaoContent,jdbcType=LONGVARCHAR}",
        "where jianbao_id = #{jianbaoId,jdbcType=INTEGER}"
    })
    int updateByPrimaryKeyWithBLOBs(JianBao record);

    @Update({
        "update jianbao",
        "set title = #{title,jdbcType=VARCHAR},",
          "creator = #{creator,jdbcType=VARCHAR},",
          "createtime = #{createtime,jdbcType=TIMESTAMP},",
          "updator = #{updator,jdbcType=VARCHAR},",
          "updatetime = #{updatetime,jdbcType=TIMESTAMP}",
        "where jianbao_id = #{jianbaoId,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(JianBao record);
    @Select({
        "select",
        "jianbao_id, title, creator, createtime, updator, updatetime, jianbao_content",
        "from jianbao"
    })
    @Results({
        @Result(column="jianbao_id", property="jianbaoId", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="title", property="title", jdbcType=JdbcType.VARCHAR),
        @Result(column="creator", property="creator", jdbcType=JdbcType.VARCHAR),
        @Result(column="createtime", property="createtime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="updator", property="updator", jdbcType=JdbcType.VARCHAR),
        @Result(column="updatetime", property="updatetime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="jianbao_content", property="jianbaoContent", jdbcType=JdbcType.LONGVARCHAR)
    })
    List<JianBao> findAll();
}